package com.sgcc.ln.pmos.e_ln_mall.adapter;

import android.view.View;
import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.sgcc.ln.pmos.common.bean.PowMonth;
import com.sgcc.ln.pmos.common.bean.PowMonthCoye;
import com.sgcc.pmos.nativesdk.R;

public class PowersetChartAdapter extends BaseQuickAdapter<PowMonthCoye, BaseViewHolder> {
    int lastPosition = 0;
    private String year;

    public PowersetChartAdapter() {
        super(R.layout.item_month_chart);
    }

    public void setYear(String year) {
        this.year = year;
    }

    public interface OnItemClickListener {
//        //加入收藏
//        void OnAddCollectionListener(int position, String s);
//
//        //加入对比
//        void OnAddContrastListener(int position, String s);

        //条目点击
        void OnItemsClickListener(int position, PowMonth s, int lastPosition);
    }

    private OnItemClickListener mOnItemClickListener;

    public void setItemClickListener(OnItemClickListener onItemClickListener) {
        this.mOnItemClickListener = onItemClickListener;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, PowMonthCoye s) {
        baseViewHolder.setText(R.id.month_txt, year+"年"+s.getPowMonth().getMonthDate()+"月");
        LinearLayout ground = baseViewHolder.getView(R.id.ground);
        if ((boolean) s.isSelect()) {
            ground.setBackgroundResource(R.drawable.edit_box_check);
            baseViewHolder.setTextColor(R.id.month_txt, 0xff3274F0);
        } else {
            ground.setBackgroundResource(R.drawable.edit_box);
            baseViewHolder.setTextColor(R.id.month_txt, 0xff999999);
        }
        ground.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mOnItemClickListener != null) {
                    mOnItemClickListener.OnItemsClickListener(getItemPosition(s), s.getPowMonth(), lastPosition);
                }
                lastPosition = getItemPosition(s);
            }
        });
    }



}
